<?php

class TrackLogTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\TrackLog\TrackLogClass();
		$class['sid'] = $this->testNum();
		$class['pid'] = $this->testNum();
		$class['resource'] = $this->testStr();
		$class['timestamp'] = $this->testNum();
		$class['oid'] = $this->testStr();
		$class['cid'] = $this->testStr();
		$class['uid'] = $this->testStr();
		$class['guid'] = $this->testStr();


        $class->insert();
        $result_class = new \Orm\TrackLog\TrackLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['sid'],$result_class['sid']);
		$this->assertEquals($class['pid'],$result_class['pid']);
		$this->assertEquals($class['resource'],$result_class['resource']);
		$this->assertEquals($class['timestamp'],$result_class['timestamp']);
		$this->assertEquals($class['oid'],$result_class['oid']);
		$this->assertEquals($class['cid'],$result_class['cid']);
		$this->assertEquals($class['uid'],$result_class['uid']);
		$this->assertEquals($class['guid'],$result_class['guid']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['sid'] = $this->testNum();
		$class['pid'] = $this->testNum();
		$class['resource'] = $this->testStr();
		$class['timestamp'] = $this->testNum();
		$class['oid'] = $this->testStr();
		$class['cid'] = $this->testStr();
		$class['uid'] = $this->testStr();
		$class['guid'] = $this->testStr();


        $class->update();
        $result_class = new \Orm\TrackLog\TrackLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['sid'],$result_class['sid']);
		$this->assertEquals($class['pid'],$result_class['pid']);
		$this->assertEquals($class['resource'],$result_class['resource']);
		$this->assertEquals($class['timestamp'],$result_class['timestamp']);
		$this->assertEquals($class['oid'],$result_class['oid']);
		$this->assertEquals($class['cid'],$result_class['cid']);
		$this->assertEquals($class['uid'],$result_class['uid']);
		$this->assertEquals($class['guid'],$result_class['guid']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\TrackLog\TrackLogClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}